package cn.sunjinxin.trade.application.convert;

import cn.hutool.core.bean.BeanUtil;
import cn.sunjinxin.trade.client.api.request.OrderCreateRequest;
import cn.sunjinxin.trade.client.api.request.OrderRequest;
import cn.sunjinxin.trade.domain.model.entity.Distributor;
import cn.sunjinxin.trade.domain.model.entity.Traveler;
import org.jetbrains.annotations.NotNull;

import java.util.ArrayList;
import java.util.List;

/**
 * @author issavior
 */
public class PreorderConvert {

    @NotNull
    public static List<Traveler> getTravelers(OrderRequest request) {
        List<Traveler> traveler = new ArrayList<>();
        BeanUtil.copyProperties(request.getTraveler(), traveler);
        return traveler;
    }

    @NotNull
    public static List<Traveler> getTravelers(OrderCreateRequest request) {
        List<Traveler> traveler = new ArrayList<>();
        BeanUtil.copyProperties(request.getTraveler(), traveler);
        return traveler;
    }

    @NotNull
    public static Distributor getDistributor(OrderRequest request) {
        Distributor distributor = new Distributor();
        distributor.setDistributorId(request.getDistributorId());
        distributor.setOutOrderId(request.getOutOrderNo());
        return distributor;
    }

    @NotNull
    public static Distributor getDistributor(OrderCreateRequest request) {
        Distributor distributor = new Distributor();
        distributor.setDistributorId(request.getDistributorId());
        distributor.setOutOrderId(request.getOutOrderNo());
        return distributor;
    }
}
